<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>Aloha Editor command bold tests</title>
	<!-- include qunit -->
	<link rel="stylesheet" href="../vendor/qunit.css" type="text/css"/>

	<script type="text/javascript" src="../vendor/qunit.js"></script>

	<!-- include jquery -->
	<script	src="../../lib/vendor/jquery-1.7.2.js" ></script>
	<script type="text/javascript" src="../vendor/jquery.simulate.js"></script>

	<!-- include aloha -->
	<script>
		Aloha = { jQuery: $, settings: { jQuery: $ } };
	</script>
	<script src="../../lib/require.js"></script>
	<script src="../../lib/aloha.js"></script>

	<!-- inject into testswarm -->
	<script type="text/javascript" src="../vendor/swarminject.js"></script>
	<script>
		// load command test suite
		require( ['commandtest'] );
	</script>
	<style type="text/css">
		.aloha-editable ol li { list-style-type: decimal; margin: 1.5em; }
		.aloha-editable ol li ol li{ list-style-type: decimal; margin: 2em; }
	</style>
</head>
<body>
	<!-- include the tests -->
	<script>
	var tests = {
			defaultValue: '',
			defaultCommand: 'bold',
			defaultAttributes: [ 'font-weight' ],
			tests: [		        
					{  	start: 'fo[o<b>b]ar</b>baz',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: 'foo<b>ba[r</b>b]az',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: 'fo[o<b>bar</b>b]az',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: 'foo[<b>b]ar</b>baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'foo<b>ba[r</b>]baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'foo[<b>bar</b>]baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'foo<b>[bar]</b>baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'foo{<b>bar</b>}baz',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: 'fo[o<span style=font-weight:bold>b]ar</span>baz',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: '<span style=font-weight:800>fo[o</span><span style=font-weight:900>b]ar</span>',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: '<span style=font-weight:700>fo[o</span><span style=font-weight:800>b]ar</span>',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: '<span style=font-weight:600>fo[o</span><span style=font-weight:700>b]ar</span>',
					   	indetermResult: false,
					   	stateResult: true
					},
					{  	start: '<span style=font-weight:500>fo[o</span><span style=font-weight:600>b]ar</span>',
					   	indetermResult: true,
					   	stateResult: false
					},
					{  	start: '<span style=font-weight:400>fo[o</span><span style=font-weight:500>b]ar</span>',
					   	indetermResult: false,
					   	stateResult: false
					},
					{  	start: '<span style=font-weight:300>fo[o</span><span style=font-weight:400>b]ar</span>',
					   	indetermResult: false,
					   	stateResult: false
					},
					{  	start: '<span style=font-weight:200>fo[o</span><span style=font-weight:300>b]ar</span>',
					   	indetermResult: false,
					   	stateResult: false
					},
					{  	start: '<span style=font-weight:100>fo[o</span><span style=font-weight:200>b]ar</span>',
					   	indetermResult: false,
					   	stateResult: false
					},
/*					{  	start: 'foo[bar]baz',
				       	execResult: 'foo<b>[bar]</b>baz'
				    },
*/					{  	start: 'foo<b>[bar]</b>baz',
				       	execResult: 'foo[bar]baz'
				    },
					{  	start: 'foo<b>[bar</b>]baz',
				       	execResult: 'foo[bar]baz' 
				    },
					{  	start: 'foo<b>b[ar</b>]baz',
				       	execResult: 'foo<b>b</b>[ar]baz' 
				    },
/*					{  	start: 'foo<b>bar[</b>b]az',
				       	execResult: 'foo<b>bar[b]</b>az'
				    },
					{  	start: 'foo<b>bar[</b>b]az',
				       	execResult: 'foo<b>bar[b]</b>az' 
				    },
*/					{  	start: 'foo[]bar',
				       	execResult: 'foo[]bar' 
				    },
					{  	start: '<b>foo[]bar</b>',
				       	execResult: '<b>foo[]bar</b>' 
				    },
					{  	start: '<span>foo</span>{}<span>bar</span>',
				       	execResult: '<span>foo[]</span><span>bar</span>' 
				    },
					{  	start: '<span>foo[</span><span>]bar</span>',
				       	execResult: '<span>foo[]</span><span>bar</span>' 
				    },
					{  	start: 'foo[bar<i>bam]baz</i>',
				       	execResult: 'foo<b>[bar</b><i><b>bam]</b>baz</i>' 
				    },
					{  	start: 'foo<span contenteditable=false>[bar]</span>baz',
					   	execResult: 'foo<span contenteditable=false>[bar]</span>baz' 
					},
					{  	start: 'fo[o<span contenteditable=false>bar</span>b]az',
					   	execResult: 'fo<b>[o</b><span contenteditable=false>bar</span><b>b]</b>az' 
					},
					{  	start: 'foo<span contenteditable=false>ba[r]</span>baz',
					   	execResult: 'foo<span contenteditable=false>ba[r]</span>baz' 
					},
					{  	start: 'fo[o<span contenteditable=false>b]ar</span>baz',
					   	execResult: 'fo<b>[o]</b><span contenteditable=false>bar</span>baz' 
					},
					{  	start: 'fo[<b>o</b><span contenteditable=false>bar</span><b>b</b>]az',
					   	execResult: 'fo[o<span contenteditable=false>bar</span>b]az' 
					},
					{  	start: '<span contenteditable=false>foo<span contenteditable=true>[bar]</span>baz</span>',
					   	execResult: '<span contenteditable=false>foo<span contenteditable=true><b>[bar]</b></span>baz</span>' 
					},
					{  	start: '<span contenteditable=false>fo[o<span contenteditable=true>bar</span>b]az</span>',
					   	execResult: '<span contenteditable=false>fo[o<span contenteditable=true><b>bar</b></span>b]az</span>' 
					},
					{  	start: '<span contenteditable=false>foo<span contenteditable=true>ba[r</span>b]az</span>',
					   	execResult: '<span contenteditable=false>foo<span contenteditable=true>ba<b>[r]</b></span>baz</span>' 
					},
					{  	start: '<span contenteditable=false>fo[o<span contenteditable=true>b]ar</span>baz</span>',
					   	execResult: '<span contenteditable=false>fo[o]<span contenteditable=true>bar</span>baz</span>' 
					},
					{  	start: '<span contenteditable=false>fo[<b>o<span contenteditable=true>bar</span>b</b>]az</span>',
					   	execResult: '<span contenteditable=false>fo<b>[o<span contenteditable=true><span style="font-weight: normal;">bar</span></span>b]</b>az</span>' 
					},
					{  	start: '<table><tbody><tr><td>foo<td>b[a]r<td>baz</table>',
					   	execResult: '<table><tbody><tr><td>foo<td>b<b>[a]</b>r<td>baz</table>' 
					},
					{  	start: '<table><tbody><tr data-start=1 data-end=2><td>foo<td>bar<td>baz</table>',
					   	execResult: '<table><tbody><tr><td>foo<td><b>[bar</b><td>}baz</table>' 
					},
					{  	start: '<table><tbody><tr data-start=0 data-end=2><td>foo<td>bar<td>baz</table>',
					   	execResult: '<table><tbody><tr><td><b>[foo</b><td><b>bar</b><td>}baz</table>' 
					},
					{  	start: '<table><tbody data-start=0 data-end=1><tr><td>foo<td>bar<td>baz</table>',
					   	execResult: '<table><tbody><tr><td><b>[foo</b><td><b>bar</b><td><b>baz</b></table>}' 
					},
					{  	start: '<table data-start=0 data-end=1><tbody><tr><td>foo<td>bar<td>baz</table>',
					   	execResult: '{<table><tbody><tr><td><b>foo</b><td><b>bar</b><td><b>baz</b></table>}' 
					},
					{  	start: '{<table><tr><td>foo<td>bar<td>baz</table>}',
					   	execResult: '{<table><tr><td><b>foo</b><td><b>bar</b><td><b>baz</b></table>}' 
					},
					{  	start: 'foo<span style="font-weight: bold">[bar]</span>baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: 'foo<b>[bar]</b>baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: 'foo<b>bar</b>[baz]',
					   	execResult: 'foo<b>bar[baz]</b>' 
					},
					{  	start: '[foo]<b>bar</b>baz',
					   	execResult: '<b>[foo]bar</b>baz' 
					},
					{  	start: '<b>foo</b>[bar]<b>baz</b>',
					   	execResult: '<b>foo[bar]baz</b>' 
					},
					{  	start: 'foo<strong>bar</strong>[baz]',
					   	execResult: 'foo<strong>bar</strong><b>[baz]</b>' 
					},
					{  	start: '[foo]<strong>bar</strong>baz',
					   	execResult: '<b>[foo]</b><strong>bar</strong>baz' 
					},
					{  	start: '<strong>foo</strong>[bar]<strong>baz</strong>',
					   	execResult: '<strong>foo</strong><b>[bar]</b><strong>baz</strong>' 
					},
					{  	start: '<b>foo</b>[bar]<strong>baz</strong>',
					   	execResult: '<b>foo[bar]</b><strong>baz</strong>' 
					},
					{  	start: '<strong>foo</strong>[bar]<b>baz</b>',
					   	execResult: '<strong>foo</strong><b>[bar]baz</b>' 
					},
					{  	start: 'foo[<b>bar</b>]baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: 'foo[<b>bar]</b>baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: 'foo<b>[bar</b>]baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: 'foo{<b></b>}baz',
					   	execResult: 'foo[]baz' 
					},
					{  	start: 'foo{<i></i>}baz',
					   	execResult: 'foo[]baz' 
					},
					{  	start: 'foo{<b><i></i></b>}baz',
					   	execResult: 'foo[]baz' 
					},
					{  	start: 'foo{<i><b></b></i>}baz',
					   	execResult: 'foo[]baz' 
					},
					{  	start: 'foo<strong>[bar]</strong>baz',
					   	execResult: 'foo<b>[bar]</b>baz' 
					},
					{  	start: 'foo[<strong>bar</strong>]baz',
					   	execResult: 'foo<b>[bar]</b>baz' 
					},
					{  	start: 'foo[<strong>bar]</strong>baz',
					   	execResult: 'foo<b>[bar]</b>baz' 
					},
					{  	start: 'foo<strong>[bar</strong>]baz',
					   	execResult: 'foo<b>[bar]</b>baz' 
					},
					{  	start: 'foo<span style="font-weight: bold">[bar]</span>baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: 'foo[<span style="font-weight: bold">bar</span>]baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: 'foo[<span style="font-weight: bold">bar]</span>baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: 'foo<span style="font-weight: bold">[bar</span>]baz',
					   	execResult: 'foo[bar]baz' 
					},
					{  	start: '<b>{<p>foo</p><p>bar</p>}<p>baz</p></b>',
					   	execResult: '<p>[foo</p><p>bar</p><p>}<b>baz</b></p>' 
					},
					{  	start: '<p>[foo</p><p>bar]</p><b><p>baz</p></b>',
						indetermStart: false,
						stateStart: false,
					   	execResult: '<p><b>[foo</b></p><p><b>bar]</b></p><b><p>baz</p></b>', 
						indetermResult: false,
						stateResult: true   
					},
					{  	start: 'foo [bar <b>baz] bam</b> bom',
						indetermStart: true,
						stateStart: false,
					   	execResult: 'foo <b>[bar baz] bam</b> bom', 
						indetermResult: false,
						stateResult: true,
					   	execToggle: 'foo [bar baz]<b> bam</b> bom', 
						indetermToggle: false,
						stateToggle: false
					},
					{  	start: 'foo <b>[bar baz] bam</b> bom',
						stateStart: true,
					   	execResult: 'foo [bar baz]<b> bam</b> bom', 
						stateResult: false   
					},
					{  	start: '<b><p>foo[<i>bar</i>}</p><p>baz</p></b>',
						stateStart: true,
					   	execResult: '<p><b>foo</b><i>[bar]</i></p><p><b>baz</b></p>', 
						stateResult: false   
					},
					{  	start: '<b><p>foo</p></b><i>[bar</i>}<b><p>baz</p></b>',
						stateStart: false,
					   	execResult: '<b><p>foo</p><i>[bar]</i><p>baz</p></b>', 
						stateResult: true,   
					   	execToggle: '<p><b>foo</b></p><i>[bar]</i><p><b>baz</b></p>', 
						stateToggle: false   
					},
					{  	start: 'foo bar <b>baz [bam</b> bom] bus',
						indetermStart: true,
						stateStart: false,
					   	execResult: 'foo bar <b>baz [bam bom]</b> bus', 
						indetermResult: false,
						stateResult: true   
					},
					{  	start: '<b id=purple>bar [baz] qoz</b>',
						stateStart: true,
					   	execResult: '<span id=purple><b>bar </b>[baz]<b> qoz</b></span>', 
						stateResult: false   
					},
/** No want			{  	start: '<h3>foo[bar]baz</h3>',
					   	execResult: '<h3>foo[bar]baz</h3>' 
					},
					{  	start: '{<h3>foobar]baz</h3',
					   	execResult: '{<h3>foobar]baz</h3' 
					},
					{  	start: '<h3>foo[barbaz</h3>}',
					   	execResult: '<h3>foo[barbaz</h3>}' 
					},
					{  	start: '<h3>[foobarbaz]</h3>',
					   	execResult: '<h3>[foobarbaz]</h3>' 
					},
					{  	start: '{<h3>foobarbaz]</h3>',
					   	execResult: '{<h3>foobarbaz]</h3>' 
					},
					{  	start: '<h3>[foobarbaz</h3>}',
					   	execResult: '<h3>[foobarbaz</h3>}' 
					},
					{  	start: '{<h3>foobarbaz</h3>}',
					   	execResult: '{<h3>foobarbaz</h3>}' 
					},
					{  	start: '{<b>foo</b> <b>bar</b>}',
					   	execResult: '<b>[foo bar]</b>'
					},
					{  	start: '{<h3>foo</h3><b>bar</b>}',
					   	execResult: '<h3><span style="font-weight: normal;">[foo</span></h3>bar]'
					},
**/					{  	start: '<i><b>foo</b></i>[bar]<i><b>baz</b></i>',
					   	execResult: '<b><i>foo</i>[bar]<i>baz</i></b>'
					},
					{  	start: '<b>foo</b>[bar]<i><b>baz</b></i>',
					   	execResult: '<b>foo[bar]<i>baz</b></i>'
					},
					{  	start: '<font color=blue face=monospace><b>foo</b></font>[bar]',
					   	execResult: '<b><font color=blue face=monospace>foo</font>[bar]</b>'
					},
					{  	start: '<b>foo<span style="font-weight: normal">bar<b>[baz]</b>quz</span>qoz</b>',
						indetermStart: false,
						stateStart: true,
					   	execResult: '<b>foo<span style="font-weight: normal">bar[baz]quz</span>qoz</b>',
						indetermResult: false,
						stateResult: false
					},
					{  	start: '<b>foo<span style="font-weight: normal">[bar]</span>baz</b>',
					   	execResult: '<b>foo[bar]baz</b>'
					},
					{  	start: 'foo<span style="font-weight: normal"><b>{bar}</b></span>baz',
						stateStart: true,
					   	execResult: 'foo[bar]baz',
						stateResult: false,
					   	execToggle: 'foo<b>[bar]</b>baz',
						stateToggle: true
					},
					{  	start: 'foo<span style="font-weight: normal; color: red"><b>{bar}</b></span>baz',
					   	execResult: 'foo<span style="color: red">[bar]</span>baz'
					},
					{  	start: '[foo<span class=notbold>bar</span>baz]',
					   	execResult: '<b>[foo<span class=notbold><b>bar</b></span>baz]</b>'
					},
					{  	start: '<b><span class=notbold>[foo]</span></b>',
						stateResult: false,
					   	execResult: '<span class=notbold><b>[foo]</b></span>',
						stateResult: true
					},
					{  	start: '<b><span class=notbold>foo[bar]baz</span></b>',
					   	execResult: '<b><span class=notbold>foo<b>[bar]</b>baz</span></b>'
					},
					{  	start: '<p style="font-weight: bold">foo[bar]baz</p>',
					   	execResult: '<p><b>foo</b>[bar]<b>baz</b></p>'
					},
					{  	start: 'foo<span style="font-weight: 100;">[bar]</span>baz',
					   	execResult: 'foo<b>[bar]</b>baz'
					},
					{  	start: 'foo<span style="font-weight: 200">[bar]</span>baz',
					   	execResult: 'foo<b>[bar]</b>baz'
					},
					{  	start: 'foo<span style="font-weight: 300">[bar]</span>baz',
					   	execResult: 'foo<b>[bar]</b>baz'
					},
					{  	start: 'foo<span style="font-weight: 400">[bar]</span>baz',
					   	execResult: 'foo<b>[bar]</b>baz'
					},
					{  	start: 'foo<span style="font-weight: 500">[bar]</span>baz',
					   	execResult: 'foo<b>[bar]</b>baz'
					},
					{  	start: 'foo<span style="font-weight: 600">[bar]</span>baz',
					   	execResult: 'foo[bar]baz'
					},
					{  	start: 'foo<span style="font-weight: 700">[bar]</span>baz',
					   	execResult: 'foo[bar]baz'
					},
					{  	start: 'foo<span style="font-weight: 800">[bar]</span>baz',
					   	execResult: 'foo[bar]baz'
					},
					{  	start: 'foo<span style="font-weight: 900">[bar]</span>baz',
					   	execResult: 'foo[bar]baz'
					},
					{  	start: 'foo<span style="font-weight: 400">[bar</span>]baz',
					   	execResult: 'foo<b>[bar]</b>baz'
					},
					{  	start: 'foo<span style="font-weight: 700">[bar</span>]baz',
					   	execResult: 'foo[bar]baz'
					},
					{  	start: 'foo[<span style="font-weight: 400">bar]</span>baz',
					   	execResult: 'foo<b>[bar]</b>baz'
					},
					{  	start: 'foo[<span style="font-weight: 700">bar]</span>baz',
					   	execResult: 'foo[bar]baz'
					},
					{  	start: 'foo[<span style="font-weight: 400">bar</span>]baz',
					   	execResult: 'foo<b>[bar]</b>baz'
					},
					{  	start: 'foo[<span style="font-weight: 700">bar</span>]baz',
					   	execResult: 'foo[bar]baz'
					},
					{  	start: '<span style="font-weight: 100">foo[bar]baz</span>',
					   	execResult: '<span style="font-weight: 100">foo<b>[bar]</b>baz</span>'
					},
					{  	start: '<span style="font-weight: 400">foo[bar]baz</span>',
					   	execResult: '<span style="font-weight: 400">foo<b>[bar]</b>baz</span>'
					},
					{  	start: '<span style="font-weight: 700">foo[bar]baz</span>',
					   	execResult: '<b>foo</b>[bar]<b>baz</b>'
					},
					{  	start: '<span style="font-weight: 900">foo[bar]baz</span>',
					   	execResult: '<span style="font-weight: 900">foo</span>[bar]<span style="font-weight: 900">baz</span>'
					},
					{  	start: '{<span style="font-weight: 100">foobar]baz</span>',
					   	execResult: '<span style="font-weight: 100"><b>[foobar]</b>baz</span>'
					},
					{  	start: '{<span style="font-weight: 400">foobar]baz</span>',
					   	execResult: '<span style="font-weight: 400"><b>[foobar]</b>baz</span>'
					},
					{  	start: '{<span style="font-weight: 700">foobar]baz</span>',
					   	execResult: '[foobar]<b>baz</b>'
					},
					{  	start: '{<span style="font-weight: 900">foobar]baz</span>',
					   	execResult: '[foobar]<span style="font-weight: 900">baz</span>'
					},
					{  	start: '<span style="font-weight: 100">foo[barbaz</span>}',
					   	execResult: '<span style="font-weight: 100">foo<b>[barbaz]</b></span>'
					},
					{  	start: '<span style="font-weight: 400">foo[barbaz</span>}',
					   	execResult: '<span style="font-weight: 400">foo<b>[barbaz]</b></span>'
					},
					{  	start: '<span style="font-weight: 700">foo[barbaz</span>}',
					   	execResult: '<b>foo</b>[barbaz]'
					},
					{  	start: '<span style="font-weight: 900">foo[barbaz</span>}',
					   	execResult: '<span style="font-weight: 900">foo</span>[barbaz]'
					}
			]
	}
	</script>
	<h1 id="qunit-header">Aloha Editor command bold tests</h1>
	<h2 id="qunit-banner"></h2>
	<div id="qunit-testrunner-toolbar"></div>
	<h2 id="qunit-userAgent"></h2>
	<ol id="qunit-tests"></ol>
	<div id="qunit-fixture"></div>
	<div id="edit" style="margin:20px; border:1px solid #000000;"></div>
	<div id="logBody"></div>
	</div>
</body>
</html>
